package homework.extendwork4.coding;

import java.util.Objects;

public class Fruits {
    private String strShape;
    private  String strTaste;
    public Fruits(String strShape,String strTaste){
        this.setStrShape(strShape);
        this.setStrTaste(strTaste);

    }
    public void eat(){
        System.out.println("水果可供人食用");
    }

    public String getStrShape() {
        return strShape;
    }

    public void setStrShape(String strShape) {
        this.strShape = strShape;
    }

    public String getStrTaste() {
        return strTaste;
    }

    public void setStrTaste(String strTaste) {
        this.strTaste = strTaste;
    }

    @Override
    public boolean equals(Object o) {
        if (o==null) return false;
        if (o.getClass() !=this.getClass())return false;
        Fruits f=(Fruits) o;
        return (Objects.equals(f.getStrTaste(), this.getStrTaste()) && Objects.equals(f.getStrShape(), this.getStrShape()));


    }


//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Fruits fruits = (Fruits) o;
//        return Objects.equals(strShape, fruits.strShape) && Objects.equals(strTaste, fruits.strTaste);
//    }

    @Override
    public int hashCode() {
        return Objects.hash(strShape, strTaste);
    }
}
